// import log from '@dfeidao/atom-nodejs/logger/log';

import { IncomingHttpHeaders } from 'http';
import query from '@dfeidao/atom-nodejs/db/query';
import { systemid, productid } from '../../atom/config';
import format from '@dfeidao/atom-nodejs/dt/format';
interface Message {
	event_no: string;


}
interface Par {
	event_time: string
}



export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
	// log('Service begin path:e:\7.29考核\kh\src\LiQiuLiang\zj-000007\s001,action_id:' + action_id);


	const q = query(action_id, action_id, systemid)
	q.prepare('burst_event', ['event_theme', 'event_location', 'event_record', 'process_result', 'cause_analysis', 'precaution', 'principal_opinion', 'memo', 'event_no', 'event_time', 'resume_attachment', 'management_office', 'principal_part'], { productid, event_no: message.event_no }, 2, 1, [], []);


	const [qq] = await q.exec<Par>();
	const res2 = qq.map((v) => {
		const nowdate = new Date(v.event_time).getTime();
		const new_date = format(nowdate, 'YYYY-MM-DD');
		return { ...v, new_date };
	})





	const res = query(action_id, session_id, systemid);
	res.prepare('security_architecture', ['safety_department_no', 'safety_department_name'], { productid, }, 200, 1, [], []);

	const [d] = await res.exec();

	const res1 = query(action_id, session_id, systemid);
	res1.prepare('security_architecture', ['safety_department_no', 'safety_department_name'], { productid, }, 200, 1, [], []);

	const [q1] = await res1.exec();

	// log('Service end path:e:\7.29考核\kh\src\LiQiuLiang\zj-000007\s001,action_id:' + action_id);
	return { qq, d, q1, res2 }
}
